<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-wdInfo-edit" th:object="${wdInfo}">
            <input id="wdId" name="wdId" th:field="*{wdId}"  type="hidden">
            <div class="form-group">	
                <label class="col-sm-3 control-label">年：</label>
                <div class="col-sm-8">
                    <input id="wdYear" name="wdYear" th:field="*{wdYear}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">月：</label>
                <div class="col-sm-8">
                    <input id="wdMonth" name="wdMonth" th:field="*{wdMonth}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">日：</label>
                <div class="col-sm-8">
                    <input id="wdDay" name="wdDay" th:field="*{wdDay}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">日期：</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control time-input" id="wdDate" name="wdDate" th:value="${#dates.format(wdInfo.wdDate, 'yyyy-MM-dd')}" />
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">星期：</label>
                <div class="col-sm-8">
                    <input id="wdWeek" name="wdWeek" th:field="*{wdWeek}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">日期类型：</label>
                <div class="col-sm-8">
                    <select id="wdDtType" class="form-control m-b" th:with="type=${@dict.getType('pm_date_type')}">
	                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{wdDtType}"></option>
	                </select>
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input id="wdNote" name="wdNote" th:field="*{wdNote}" class="form-control" type="text">
                </div>
            </div>
		</form>
    </div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "pm/wdInfo"
		$("#form-wdInfo-edit").validate({
			rules:{
				wdYear:{
        			required:true
        		},
        		wdMonth:{
        			required:true
        		},
        		wdDay:{
        			required:true
        		}
			}
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	edit();
	        }
	    }
		
		layui.use('laydate', function(){
			var laydate = layui.laydate;
			laydate.render({
				elem: '#wdDate',
				theme: 'default',
		        trigger: 'click'
			});
		});
		
		function edit() {
			var wdId = $("input[name='wdId']").val();
			var wdYear = $("input[name='wdYear']").val();
        	var wdMonth = $("input[name='wdMonth']").val();
        	var wdDay = $("input[name='wdDay']").val();
        	var wdDate = $("#wdDate").val();
        	var wdWeek = $("input[name='wdWeek']").val();
        	var wdDtType = $("#wdDtType option:selected").val();
        	var wdNote = $("input[name='wdNote']").val();
        	$.ajax({
        		cache : true,
        		type : "POST",
        		url : ctx + "pm/wdInfo/edit",
        		data : {
        			"wdId": wdId,
        			"wdYear": wdYear,
        			"wdMonth": wdMonth,
        			"wdDay": wdDay,
        			"wdDate": wdDate,
        			"wdWeek": wdWeek,
        			"wdDtType": wdDtType,
        			"wdNote": wdNote
        		},
        		async : true,
        		error : function(request) {
        			$.modal.alertError("系统错误");
        		},
        		success : function(data) {
        			$.operate.saveSuccess(data);
        		}
        	});
        }
	</script>
</body>
</html>
